import pyautogui, sys

if __name__ == '__main__':
    pyautogui.PAUSE = 1.0
    print('Press Ctrl-C to quit.')
    try:
        while True:
            x, y = pyautogui.position()
            positionStr = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4)
            print(positionStr, end='')
            if "d" == input():
                break
    except KeyboardInterrupt:
        print('\n')

